package com.bcinfo.iccard.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.dao.DataAccessException;

import com.bcinfo.iccard.model.RechargeableCard;
import com.bcinfo.iccard.model.RechargeableCardInfo;
import com.bcinfo.upp.ac.model.Operator;
import com.bcinfo.upp.sys.model.SysParameter;

public interface RechargeableCardMapper
{
    int deleteByPrimaryKey(Long rechargeableCardId);

    int insert(RechargeableCard record);

    int insertSelective(RechargeableCard record);

    RechargeableCard selectByPrimaryKey(Long rechargeableCardId);

    int updateByPrimaryKeySelective(RechargeableCard record);

    int updateByPrimaryKey(RechargeableCard record);

    /**
     * 根据状态查询 用户卡列表 <br/>
     * <p>
     * Description: TODO(详细描述) <br/>
     * <p>
     * Author: Administrator<br/>
     * <p>
     * Date: 2013-12-11-下午03:19:06<br/>
     * <p>
     * 
     * @param opName
     * @param cardNum
     * @param status
     * @param benginIndex
     * @param pageSize
     * @return
     * 
     */
    List<RechargeableCardInfo> selectPageByStatus(@Param("userId") Long userId, @Param("cardNum") String cardNum,
            @Param("status") Short status, @Param("benginIndex") int benginIndex, @Param("pageSize") int pageSize);

    int selectCountByStatus(@Param("userId") Long userId, @Param("cardNum") String cardNum,
            @Param("status") Short status);

    int selectByCardNum(String cardNum);

    RechargeableCard selectCardByCardNum(String cardNum);

    List<String> selectByCardNums(@Param("cardNums") List<String> cardNums);

    List<RechargeableCard> selectByCaudNum(@Param("cardNum") String cardNum, @Param("status") int status);

    List<RechargeableCardInfo> selectByPage(@Param("cardNum") String cardNum, @Param("status") int status,
            @Param("benginIndex") int benginIndex, @Param("pageSize") int pageSize);

    int selectCountByPage(@Param("cardNum") String cardNum, @Param("status") int status);

    int updateAccountTotalByCardId(@Param("rechargeableCardId") Long rechargeableCardId,
            @Param("operate") String action, @Param("num") float num);

    List<RechargeableCardInfo> selectDetailPageByCardNum(@Param("userId") Long userId,
            @Param("cardNum") String cardNum, @Param("beginTime") String beginTime, @Param("endTime") String endTime,
            @Param("benginIndex") int benginIndex, @Param("pageSize") int pageSize);

    int selectDetailCountByCardNum(@Param("userId") Long userId, @Param("cardNum") String cardNum,
            @Param("beginTime") String beginTime, @Param("endTime") String endTime);

    /**
     * 
     * 根据卡号查询卡信息 <br/>
     * <p>
     * Description: TODO(详细描述) <br/>
     * <p>
     * Author: Administrator<br/>
     * <p>
     * Date: 2013-12-4-上午10:34:18<br/>
     * <p>
     * 
     * @param cardNum
     * @return
     * 
     */
    List<RechargeableCardInfo> selectCardInfoByCardNum(String cardNum);

    /**
     * 根据卡号，充值方式，时间查询条数 <br/>
     * <p>
     * Description: TODO(详细描述) <br/>
     * <p>
     * Author: Administrator<br/>
     * <p>
     * Date: 2013-12-9-上午11:08:47<br/>
     * <p>
     * 
     * @param cardNum
     * @param rechargeType
     * @param beginTime
     * @param endTime
     * @return
     * 
     */
    int selectDetailCountByCardNumAndRechargeType(@Param("cardNum")String cardNum,
            @Param("rechargeType") Short rechargeType, @Param("beginTime") String beginTime,
            @Param("endTime") String endTime);

    /**
     * 根据卡号，充值方式，时间查询每页信息<br/>
     * <p>
     * Description: TODO(详细描述) <br/>
     * <p>
     * Author: Administrator<br/>
     * <p>
     * Date: 2013-12-9-上午11:09:08<br/>
     * <p>
     * 
     * @param cardNum
     * @param rechargeType
     * @param beginTime
     * @param endTime
     * @param benginIndex
     * @param pageSize
     * @return
     * 
     */
    List<RechargeableCardInfo> selectDetailPageByCardNumAndRechargeType(@Param("cardNum") String cardNum,
            @Param("rechargeType") Short rechargeType, @Param("beginTime") String beginTime,
            @Param("endTime") String endTime, @Param("benginIndex") int benginIndex, @Param("pageSize") int pageSize);

    List<Operator> selectUserByRoleId(long roleId);

    RechargeableCard load(String cardNum);

    /**
     * 搜索用户<br/>
     * <p>
     * Description: TODO(详细描述) <br/>
     * <p>
     * Author: Administrator<br/>
     * <p>
     * Date: 2013-12-10-上午11:06:25<br/>
     * <p>
     * 
     * @param keyword
     * @param maxRows
     * @return
     * 
     */
    List<Operator> selectUserByRoleIdAndUserName(@Param("keyword") String keyword, @Param("maxRows") int maxRows);

    /**
     * 充值卡预消费扣费 <br/>
     * <p>
     * Description: TODO(详细描述) <br/>
     * <p>
     * Author: wangguangchun<br/>
     * <p>
     * Date: 2013-12-12-下午03:07:24<br/>
     * <p>
     * 
     * @param cardNum
     *            卡号
     * @param amount
     *            金额
     * @return
     * 
     */
    int consume(@Param("cardNum") String cardNum, @Param("amount") float amount);

    public abstract List<SysParameter> selectByKey(@Param("key") String paramString);

    public abstract String getConfigByKey(@Param("key") String paramString);

}